[#include "/WEB-INF/pages/common/taglibs.ftl"]
[#macro _script]
	<script type="text/javascript">
		var base = (function(){
			// 事件绑定
			function _addEventListeners() {
				$('a[act=edit]').click(function(){
					var id = $(this).parent().attr('tval');
					[@c.url var="editUrl" value='/manage/Category_edit.action' scope="page"]
						[#--[@c.param name="categoryId" value="${categoryId}"/]--]
					[/@c.url]
					
					window.location = "${editUrl}?categoryId=" + id;
				})
			
				$('a[act=delete]').click(function(){
					var id = $(this).parent().attr('tval');
					$( "#delete-confirm" ).dialog({
						resizable: false,
						height:160,
						width:260,
						modal: true,
						buttons: {
							"删除": function() {
								[@c.url var="backUrl" value='/manage/Category_list.action' scope="page"]
									[@c.param name="currentPage" value="${currentPage}"/]
								[/@c.url]
								window.location = "[@c.url value='/manage/Category_delete.action?cascade='/]" + $('#cascade').attr("checked") + "&id=" + id + "&backurl=${backUrl}";
								$( this ).dialog( "close" );
							},
							"取消": function() {
								$( this ).dialog( "close" );
							}
						}
					});
					$( "#delete:ui-dialog" ).dialog( "destroy" );
					return false;
				})

            	$('.channel_review').click(function(){
            		var _$form = $(this).parents('form');
            		var _action = _$form.attr('action');
            		[@c.url var="review" value='/manage/Channel_review.action' scope="page"][/@c.url]
            		var id = $(this).attr('ckey');
            		//window.location = ${review};
            		_$form.attr('action', '${review}').attr('target', '_bank');
            		_$form.submit();
            		_$form.attr('action', _action).removeAttr('target');
            	})
            	$('.template_edit').click(function(){
					var id = $("select[name='channel.templateId']").val();
					if (id == '') {
						jAlert("请选择模板");
						return false;
					}
					[@c.url	var="editUrl" value='/manage/Template_edit.action' scope="page"]
						[@c.param name="id" value=""/]
					[/@c.url]
					var	url	= "${editUrl}" + id;
					window.location	= url;
					
				})
				//tabs
				$('#tabs').tabs({
					selected : ${idx-1}
					//,disabled: [1,2]
				});
			}
			return {
                config: {
                    theme: null
                },
                init: function () {
                    _addEventListeners();
                }
			}
		}());
	
		$(function(){
			base.config.url = "[@s.url value='/manage/Category_list.action?channelId=${channelId}'][/@s.url]";
			base.config.renderTo = "#categoryList";
			base.config.theme = getTheme();
            //Initializing the form
        	base.init();		
		})
	</script>
[/#macro]
[#if piece==true]
	[@_script /]
	<!--设置提交行为-->
	[#assign act="save" /]
	[#include "/WEB-INF/pages/manage/Channel/_channelList.ftl"]
[#else]
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Insert title here</title>
		<meta name="menu" content="CategoryMenu"/>
		<meta name="heading" content="heading"/>
		<script type="text/javascript" src="[@c.url value='/js/plugins/jquery.alerts.js'/]"></script>
		[@_script /]
	</head>
	<body id="body">
		<div class="contenttitle">
        	<h2 class="widgets"><span>频道管理</span></h2>
        </div><!--contenttitle-->
        <br />
        <div id="tabs">
			<!--设置提交行为-->
			[#assign act="save" /]
			[#include "/WEB-INF/pages/manage/Channel/_channelList.ftl"]
		 </div>
		 <br clear="all" />
		<div id="delete-confirm" style="display:none" title="删除频道">
			<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>频道删除后将无法恢复.</p>
			您确认删除吗？
		</div>
	</body>
	</html>
[/#if]